package cn.tedu.d21_socket;
import java.io.*;
/**
 * 测试 按行的读写
 */
public class TestIO {
    public static void main(String[] args) throws Exception {
        //method2();//写一行
        //method();//读一行
        method3();//读取文件并写入另一个文件

    }

    public static void method3() throws Exception {
        BufferedReader br=new BufferedReader(
                new FileReader("E:\\666\\222.txt"));
        PrintWriter pw=new PrintWriter("E:\\666\\333.txt");

        String s="";
        while ((s=br.readLine())!=null){

            pw.println(s);

        }
        pw.close();
        System.out.println("复制成功！");


    }

    public static void method2() throws Exception {

        PrintWriter pr=new PrintWriter("E:\\666\\111.txt");
        pr.println("apple and flower");
        pr.println("apple and flower");
        pr.println("apple and flower");
        pr.close();
    }

    public static void method() throws Exception {

        BufferedReader br=new BufferedReader(
                new FileReader("E:\\666\\111.txt"));

        String s="";
        while ((s=br.readLine())!=null) {

            System.out.println(s);

        }
        //br.close();

    }
}
